package com.yiyuan.weixin.weixinInservice.format;

import com.yiyuan.weixin.model.ReceiveXmlEntity;

import java.util.Date;

/**
 * Created by admin on 2017/3/22.
 */
public class FormatXmlMusic implements FormatXmlService {
    @Override
    public String formatXml(ReceiveXmlEntity receiveXmlEntity) {
        receiveXmlEntity.setTitle("视频消息");
        receiveXmlEntity.setDescription("视频消息的描述");
        receiveXmlEntity.setMusicURL("http://up.mcyt.net/md5/53/NjI3NDE1OQ_Qq4329912.mp3");
        receiveXmlEntity.setHQMusicUrl("http://up.mcyt.net/md5/53/NjI3NDE1OQ_Qq4329912.mp3");
        receiveXmlEntity.setThumbMediaId("MyCwu7067hWVQMgLkiesyphpL-2UrbqL28c_NDGsNmkzTIiXdzWI_e_1VCxow074");


        StringBuffer sb = new StringBuffer();
        Date date = new Date();
        sb.append("<xml><ToUserName><![CDATA[");
        sb.append(receiveXmlEntity.getFromUserName());
        sb.append("]]></ToUserName><FromUserName><![CDATA[");
        sb.append(receiveXmlEntity.getToUserName());
        sb.append("]]></FromUserName><CreateTime>");
        sb.append(date.getTime());
        sb.append("</CreateTime><MsgType><![CDATA[music]]></MsgType><Music><Title><![CDATA[");
        sb.append(receiveXmlEntity.getTitle());
        sb.append("]]></Title><Description><![CDATA[");
        sb.append(receiveXmlEntity.getDescription());
        sb.append("]]></Description><MusicUrl><![CDATA[");
        sb.append(receiveXmlEntity.getMusicURL());
        sb.append("]]></MusicUrl><HQMusicUrl><![CDATA[");
        sb.append(receiveXmlEntity.getHQMusicUrl());
        sb.append("]]></HQMusicUrl><ThumbMediaId><![CDATA[");
        sb.append(receiveXmlEntity.getMediaId());
        sb.append("]]></ThumbMediaId></Music></xml>");
        return sb.toString();

    }
}